package com.fh.utils.mq;


import com.alibaba.fastjson2.JSON;
import com.fh.dto.User;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

// topic需要和生产者的topic一致，consumerGroup属性是必须指定的，内容可以随意
// selectorExpression的意思指的就是tag，默认为“*”，不设置的话会监听所有消息
@Component
@Slf4j
@RocketMQMessageListener( topic = "RLT_TEST_TOPIC", selectorExpression = "tag1", consumerGroup = "Con_Group_One" )
public class CustomConsumerMq implements RocketMQListener<User> {
    // 监听到消息就会执行此方法
    @Override
    public void onMessage(User user) {
        log.info("监听到消息：user={} +Custom ", JSON.toJSONString(user));
    }


}

